
def main():
    predict = load_file('./result/deteted_LDF_30_300.txt')
    label = load_file('./data/seu_tcp.txt')

    # TP
    tp = 0
    for e in predict:
        if e in label:
            tp += 1

    # precision = TP / (TP + FP)
    print("Precision: ", tp / len(predict))

    # recall = TP / (TP + FN)
    print("Recall: ", tp / len(label))


def load_predict_file_1(file_path='result.txt'):
    temp = []
    with open(file_path) as f:
        temp = f.readlines()
        temp = "".join(temp).strip().lstrip("(").rstrip(")").split("), (")
    
    temp = [_.replace(",", "") for _ in temp]
    # print(len(temp))
    
    return temp

def load_file(file_path='./data/seu_tcp.txt'): 
    temp = []

    with open(file_path) as f:
        for line in f.readlines(): 
            temp.append(" ".join(line.split()[0:4]))

    temp = list(set(temp))
    print(len(temp))
    return temp

if __name__ == '__main__':
    main()